<!-- 试试index.vue如何识别 -->
<template>
  <div class="order_list">
    <search-table
      :url="url"
      ref="searchtable"
      :myTable="true"
      :columns="columns"
      :hideSelect="true"
      :form="form"
      :default-params="defaultParams"
      @dataSourceChange="dataSourceChange"
    >
      <template slot="searchForm">
        <a-form layout="inline" :form="form">
          <a-form-item label="商品名称">
            <a-input v-decorator="['goodsName']" placeholder="请输入商品名称">
            </a-input>
          </a-form-item>
          <!-- <a-form-item label="商品类型">
            <a-select
              showSearch
              allowClear
              style="width: 150px"
              :options="goodsTypeList"
              v-decorator="['goodsType']"
              placeholder="请选择"
            >
            </a-select>
          </a-form-item> -->

          <a-form-item label="收货人">
            <a-input v-decorator="['userName']" placeholder="收货人姓名/手机号">
            </a-input>
          </a-form-item>

          <a-form-item label="订单状态">
            <a-select
              showSearch
              allowClear
              style="width: 150px"
              :options="showStatusList"
              v-decorator="['orderStatus']"
              placeholder="请选择"
            >
            </a-select>
          </a-form-item>

          <a-form-item label="订单来源">
            <a-select
              showSearch
              allowClear
              style="width: 150px"
              :options="fromSource"
              v-decorator="['orderFromType']"
              placeholder="请选择"
            >
            </a-select>
          </a-form-item>

          <!--     <a-form-item label="退款状态">
            <a-select
              showSearch
              allowClear
              style="width: 150px"
              :options="withDrawStatus"
              v-decorator="['returnGoodsStatus']"
              placeholder="请选择"
            >
            </a-select>
          </a-form-item>-->

          <a-form-item label="提交时间">
            <!-- <a-date-picker
              show-time
              style="width: 240px"
              format="YYYY-MM-DD HH:mm:ss"
              v-decorator="[
                'createStartDate-createEndDate', // 提交的时候会转成 'YYYY-MM-DD HH:mm:ss'
              ]"
            /> -->
            <fast-range-picker
              allowClear
              v-decorator="['createStartDate-createEndDate']"
            >
            </fast-range-picker>
          </a-form-item>

          <a-form-item label="主订单编号">
            <a-input
              v-decorator="['orderNo']"
              allowClear
              placeholder="请输入主订单编号"
            >
            </a-input>
          </a-form-item>
          <!--注意参数-->
          <a-form-item label="子订单编号">
            <a-input
              v-decorator="['orderGoodsNo']"
              allowClear
              placeholder="请输入子订单编号"
            >
            </a-input>
          </a-form-item>

          <a-form-item label="订单类型">
            <a-select
              showSearch
              allowClear
              style="width: 200px"
              :options="orderType"
              v-decorator="['orderType']"
              placeholder="请选择"
            >
            </a-select>
          </a-form-item>

          <a-form-item label="商品类型">
            <a-select
              showSearch
              allowClear
              style="width: 200px"
              :options="productTypeList"
              v-decorator="['goodsType']"
              placeholder="选择商品类型"
            >
            </a-select>
          </a-form-item>
          <a-form-item label="下单人手机号">
            <a-input
              v-decorator="['customerPhone']"
              placeholder="请输入下单人手机号"
            >
            </a-input>
          </a-form-item>
        </a-form>
      </template>
      <template slot="oprationRow">
        <permission authority="order:export">
          <a-button type="primary" @click="exportOrders">导出</a-button>
        </permission>
        <permission authority="batch:deliver">
          <a-button type="primary" @click="batchDeliver">批量发货</a-button>
        </permission>
      </template>

      <!-- 自定义表格 -->
    </search-table>

    <div class="list">
      <div class="tab_header">
        <div class="item item--express-type">商品订单编号</div>
        <div
          class="item item--goods-info"
          style="flex: 3 1 0%; min-width: 400px"
        >
          <span class="item__cell goods-basic">商品</span>
          <span class="item__cell goods-num">单价(元) / 数量</span>
        </div>
        <div class="item item--revicer-info"><span>买家 / </span>收货人</div>
        <div class="item item--express-type">配送方式</div>
        <div class="item item--realpay">实收金额(元)</div>
        <div class="item item--order-state">订单状态</div>
        <div class="item item--realpay">es单号</div>
        <div class="item item--realpay">供应商名称</div>
        <div
          class="item item--revicer-info"
          style="text-align: right; padding-right: 12px"
        >
          操作
        </div>
      </div>

      <template v-if="orderList.length > 0">
        <div
          class="tab_content"
          v-for="(dataSourceItem, index) in orderList"
          :key="index"
        >
          <div class="order-item__header">
            <div class="basic-info">
              <div class="info-wrapper">
                <!-- <a-checkbox @change="checkboxChange($event,dataSourceItem)"></a-checkbox>-->
                <span class="basic"
                  >订单编号：{{ dataSourceItem.orderNo }}</span
                >
                <span class="basic"
                  >下单时间：{{ dataSourceItem.createDate }}</span
                >
                <span class="basic"
                  >订单来源：{{
                    dataSourceItem.orderFromType | orderFormType
                  }}</span
                >
                <span class="basic"
                  >订单类型：{{
                    getTypeName("ORDER_TYPE", dataSourceItem.orderType)
                  }}</span
                >
              </div>
              <div class="star-text">
                <!--这个状态是dataSourceItem里面的属性,根据不同状态显示不同文字-->
                <span
                  style="color: red"
                  v-if="dataSourceItem.returnGoodsStatus == null"
                ></span>
                <span
                  style="color: red"
                  v-if="dataSourceItem.returnGoodsStatus == 'TO_AUDIT'"
                  >待审核</span
                >
                <span
                  style="color: red"
                  v-if="dataSourceItem.returnGoodsStatus == 'APPROVE_AUDIT'"
                  >审核通过</span
                >
                <span
                  style="color: red"
                  v-if="dataSourceItem.returnGoodsStatus == 'REVIEW_FAILED'"
                  >审核未通过</span
                >
                <span
                  style="color: red"
                  v-if="dataSourceItem.returnGoodsStatus == 'USER_CANCEL'"
                  >用户自行取消</span
                >

                <!--               <span style="color: red" v-if="dataSourceItem.returnGoodsStatus =='WAITING_DELIVERY'">买家待发货</span>-->
                <!--               <span style="color: red" v-if="dataSourceItem.returnGoodsStatus =='WAITING_GOODS'">卖家待收货</span>-->
                <!--               <span style="color: red" v-if="dataSourceItem.returnGoodsStatus =='RECEIVED_GOODS'">卖家已收货</span>-->

                <span
                  style="color: red"
                  v-if="
                    dataSourceItem.returnGoodsStatus == 'RECEIVED_GOODS' ||
                    dataSourceItem.returnGoodsStatus == 'WAITING_GOODS' ||
                    dataSourceItem.returnGoodsStatus == 'WAITING_DELIVERY'
                  "
                  >退货中</span
                >
                <span
                  style="color: red"
                  v-if="dataSourceItem.returnGoodsStatus == 'REFUND_OF'"
                  >退款中</span
                >
                <span
                  style="color: red"
                  v-if="
                    dataSourceItem.returnGoodsStatus == 'REFUND_FINISH' &&
                    dataSourceItem.repairsType == 1
                  "
                  >已退款</span
                >
                <span
                  style="color: red"
                  v-if="
                    dataSourceItem.returnGoodsStatus == 'REFUND_FINISH' &&
                    dataSourceItem.repairsType == 2
                  "
                  >已退货退款</span
                >
                <a-button type="link" @click="openNew(dataSourceItem)">
                  查看详情
                </a-button>
                <a-button
                  type="link"
                  @click="openInfo(dataSourceItem, 'remarks')"
                >
                  备注
                </a-button>
              </div>
            </div>
          </div>
          <div class="order-item__body">
            <div class="cell cell--express-type">
              {{ dataSourceItem.orderGoodsNo }}
            </div>
            <div
              class="cell cell--goods-list"
              style="flex: 3 1 0%; min-width: 400px"
            >
              <div class="goods-item">
                <div class="goods-info">
                  <div class="rc-goods-cell rc-goods-cell-show-photo">
                    <div class="rc-goods-cell-left">
                      <div
                        class="rc-goods-cell-img rc-goods-cell-img-previewable"
                      >
                        <div
                          class="retail-lazyimage-container cover"
                          style="width: 60px; height: 60px"
                        >
                          <table-img
                            style="width: 100%; height: 100%"
                            :src="dataSourceItem.firstImg"
                          />
                        </div>
                      </div>
                    </div>
                    <div class="rc-goods-cell-right">
                      <div
                        class="rc-goods-cell-name"
                        @click="openGoodsInfo(dataSourceItem)"
                      >
                        <a
                          href="javascript:;;"
                          class="rc-blank-link"
                          rel="noopener noreferrer"
                          >{{ dataSourceItem.goodsName }}
                        </a>
                      </div>
                      <div class="rc-goods-cell-info rc-goods-cell-info-spec">
                        {{ dataSourceItem.skuName }}
                      </div>
                      <div class="rc-goods-cell-info rc-goods-cell-info-no">
                        {{ dataSourceItem.goodsCode }}
                      </div>
                      <div
                        v-if="dataSourceItem.givingName"
                        class="rc-goods-cell-info rc-goods-cell-info-no"
                      >
                        赠品：{{ dataSourceItem.givingName }}
                      </div>
                    </div>
                  </div>
                </div>
                <div class="goods-item__cell goods-num">
                  <p
                    v-if="
                      dataSourceItem.paymentWay == 0 ||
                      dataSourceItem.paymentWay == 1 ||
                      dataSourceItem.paymentWay == null
                    "
                  >
                    ¥ {{ dataSourceItem.goodsPrice | filterPrice }}元
                  </p>
                  <p v-else-if="dataSourceItem.paymentWay == 2">
                    ¥ {{ dataSourceItem.goodsPrice | filterPrice }}+{{
                      dataSourceItem.integralPrice
                    }}固定积分
                  </p>
                  <p v-else-if="dataSourceItem.paymentWay == 3">
                    {{ dataSourceItem.integralPrice }}积分
                  </p>
                  <p style="color: rgb(150, 151, 153)">
                    {{ dataSourceItem.goodsNum }} 件
                  </p>
                </div>

                <div class="goods-item__cell refund-info"></div>
              </div>
            </div>
            <div class="cell cell--receiver-info">
              <div>
                <p v-if="dataSourceItem.customerPhone">
                  <span
                    style="color: #0b59f9; cursor: pointer"
                    @click="toClientDetailPage(dataSourceItem)"
                    >{{ dataSourceItem.customerPhone || "" }}</span
                  >
                </p>
                <!--<p v-if="!!dataSourceItem.customerPhone"><a-button type="link" @click="toClientDetailPage">{{dataSourceItem.customerPhone || ''}}</a-button> </p>-->
                <p>
                  <span class="rc-blank-link">
                    {{ dataSourceItem.userName }}
                  </span>
                  <!--<router-link target="_blank" :to="{name:'CustomerUserInfo',query:{id:dataSourceItem.userId}}">{{ dataSourceItem.userPhone }}</router-link>-->
                  <!-- <a-button type="link" @click="toClientDetailPage(dataSourceItem)">
                    {{ dataSourceItem.userPhone }}
                  </a-button>-->
                </p>
                <p>
                  {{ dataSourceItem.provinceName }}
                  {{ dataSourceItem.cityName }}
                  {{ dataSourceItem.districtName }}
                  {{ dataSourceItem.detailAddress }}
                </p>
                <p>{{ dataSourceItem.userPhone }}</p>
              </div>
            </div>
            <div class="cell cell--express-type">
              {{ dataSourceItem.goodsDistribution | filterDistribution }}
            </div>
            <div class="cell cell--realpay">
              <p
                v-if="
                  dataSourceItem.paymentWay == 0 ||
                  dataSourceItem.paymentWay == 1 ||
                  dataSourceItem.paymentWay == null
                "
              >
                ¥ {{ dataSourceItem.goodsOrderPrice | filterPrice }}元
              </p>
              <p v-else-if="dataSourceItem.paymentWay == 2">
                ¥ {{ dataSourceItem.goodsOrderPrice | filterPrice }}+{{
                  dataSourceItem.integralPrice
                }}固定积分
              </p>
              <p v-else-if="dataSourceItem.paymentWay == 3">
                {{ dataSourceItem.integralPrice }}积分
              </p>
            </div>
            <div class="cell cell--order-state">
              <span v-if="dataSourceItem.returnGoodsStatus == 'REFUND_FINISH'"
                >已关闭</span
              >
              <span v-else>
                {{ dataSourceItem.orderStatus | filterOrderStatus }}</span
              >
            </div>
            <!--es单号-->
            <div class="cell cell--order-state">
              {{ dataSourceItem.erpOrderNo ? dataSourceItem.erpOrderNo : "" }}
            </div>

            <div class="cell cell--order-state">
              {{
                dataSourceItem.supplierName
                  ? dataSourceItem.supplierName
                  : "自营商品"
              }}
            </div>
            <div class="cell cell--opts">
              <div class="cell--opts__item">
                <template v-if="dataSourceItem.orderStatus == 'ORDER_UNPAID'">
                  <a-button
                    type="link"
                    @click="openInfo(dataSourceItem, 'cancellation')"
                  >
                    取消订单
                  </a-button>
                  <a-button
                    type="link"
                    @click="openInfo(dataSourceItem, 'priceChange')"
                  >
                    改价
                  </a-button>
                </template>

                <template
                  v-if="
                    dataSourceItem.orderStatus == 'ORDER_UN_ISSUE' &&
                    (dataSourceItem.returnGoodsStatus == null ||
                      dataSourceItem.returnGoodsStatus == 'REVIEW_FAILED' ||
                      dataSourceItem.returnGoodsStatus == 'USER_CANCEL')
                  "
                >
                  <a-button
                    size="small"
                    @click="openInfo(dataSourceItem, 'shoppingInfo')"
                  >
                    发货
                  </a-button>
                  <br />
                  <br />
                  <permission authority="repairs:apply">
                    <a-button
                      v-if="dataSourceItem.goodsOrderPrice != 0"
                      size="small"
                      @click="openInfo(dataSourceItem, 'withdrawMoneyInfo')"
                    >
                      退款
                    </a-button>
                  </permission>
                  <!-- <a-button
                    size="small"
                    @click="openInfo(dataSourceItem, 'shoppingInfo')"
                    >提醒供应商发货</a-button
                  > -->
                </template>

                <template
                  v-if="dataSourceItem.orderStatus == 'ORDER_LEFT_WAIT'"
                >
                  <a-button
                    size="small"
                    @click="openInfo(dataSourceItem, 'pickUpVerification')"
                  >
                    自提核销
                  </a-button>
                  <!-- <a-button
                    size="small"
                    @click="openInfo(dataSourceItem, 'shoppingInfo')"
                    >提醒供应商发货</a-button
                  > -->
                </template>
                <permission authority="print:order">
                  <a-button
                    v-show="dataSourceItem.orderStatus == 'ORDER_LEFT_WAIT'"
                    size="small"
                    @click="printOrder(dataSourceItem)"
                  >
                    打印
                  </a-button>
                </permission>
              </div>
            </div>
          </div>
          <div class="order-item__footer remark-info">
            <p>
              <span>卖家备注：</span>
              <span class="remark-info__memo">
                {{ dataSourceItem.sellerNote }}</span
              >
            </p>
          </div>
        </div>

        <a-pagination
          v-model="paginations.current"
          :page-size-options="paginations.pageSizeOptions"
          :total="paginations.total"
          :show-total="(total) => `共 ${total} 条`"
          show-size-changer
          :page-size="paginations.size"
          @showSizeChange="tableChange"
          @change="tableChange"
          class="paginations"
        >
          <template slot="buildOptionText" slot-scope="props">
            <span>{{ props.value }}条/页</span>
          </template>
        </a-pagination>
      </template>

      <template v-else>
        <img
          :src="require('@/assets/images/empty.png')"
          style="display: block; margin: 0 auto"
        />
      </template>
    </div>
    <!-- 新增备注 -->
    <add-remarks
      v-model="remarkShow"
      @handleSubmit="handleSubmit('remarks')"
      :records="currentRecord"
    />
    <!-- 取消订单 -->
    <cancellation-order
      v-model="cancellationShow"
      @handleSubmit="handleSubmit('cancellation')"
      :records="currentRecord"
    />
    <!-- 发货 -->
    <shipping-info
      v-model="shoppingInfoShow"
      @handleSubmit="handleSubmit('shoppingInfo')"
      :records="currentRecord"
    />
    <!-- 改价 -->
    <price-change
      v-model="priceChangeShow"
      @handleSubmit="handleSubmit('priceChange')"
      :records="currentRecord"
    />
    <!-- 自提核销 -->
    <pick-up-verification
      v-model="pickUpVerificationShow"
      @handleCancel="handleCancel('pickUpVerification')"
      @handleSubmit="handleSubmit('pickUpVerification')"
      :records="currentRecord"
    />
    <!-- 退款 -->
    <withdrawMoney
      :visible="withdrawMoneyInfoShow"
      @handleCancel="cancelWithdrawMoney"
      @handleSubmit="handleSubmitWithdrawMoneyInfo"
      :records="currentRecord"
    >
    </withdrawMoney>
    <!-- 批量发货 -->
    <batchDeliver
      :visible="batchDeliverShow"
      @cancel="batchDeliverShow = false"
      @submit="handleSubmitBatchDeliver"
    />
  </div>
</template>

<script>
import AddRemarks from "./components/AddRemarks";
import CancellationOrder from "./components/CancellationOrder";
import ShippingInfo from "./components/ShippingInfo";
import PriceChange from "./components/PriceChange";
import pickUpVerification from "./components/pickUpVerification";
import withdrawMoney from "./components/withdrawMoney";
import batchDeliver from "./components/batchDeliver";
import {
  createOptionsByDict,
  findDictListByType,
  findDictNameByValue,
} from "@/utils/dict";
export default {
  name: "",
  directives: {},
  mixins: [],
  model: {},
  props: {},
  components: {
    AddRemarks,
    CancellationOrder,
    ShippingInfo,
    PriceChange,
    pickUpVerification,
    withdrawMoney,
    batchDeliver,
  },
  data() {
    return {
      // defaultParams:{},
      masterOrderId: "",
      columns: [],
      orderList: [],
      currentRecord: {},
      paginations: {
        pageSizeOptions: ["10", "20", "30", "40", "50"],
        current: 1,
        size: 10,
        total: 50,
      },
      /*订单状态*/
      showStatusList: [
        {
          label: "待付款",
          value: "ORDER_UNPAID",
        },
        {
          label: "待发货",
          value: "ORDER_UN_ISSUE",
        },
        {
          label: "待收货",
          value: "ORDER_UN_RECEIVED",
        },
        {
          label: "待自提",
          value: "ORDER_LEFT_WAIT",
        },
        {
          label: "待评价",
          value: "ORDER_UN_EVALUATE",
        },
        {
          label: "已完成",
          value: "ORDER_FINISH",
        },
        {
          label: "已取消",
          value: "ORDER_CANCEL",
        },
        {
          label: "已关闭",
          value: "ORDER_CLOSE",
        },
        // {
        //   label: "售后",
        //   value: "AFTER_SALES",
        // },
      ],

      fromSource: [
        {
          label: "全部",
          value: "",
        },
        {
          label: "金桔有品小程序",
          label: "金桔有品",
          value: 1,
        },
        {
          label: "金牌厨柜官方号",
          value: 2,
        },
      ],
      /* withDrawStatus:[
          {
            label: "待审核",
            value: "TO_AUDIT",
          },
          {
            label: "审核通过",
            value: "APPROVE_AUDIT",
          },
          {
            label: "审核未通过",
            value: "REVIEW_FAILED",
          },
          {
            label: "买家待发货",
            value: "WAITING_DELIVERY",
          },

          {
            label: "卖家待收货",
            value: "WAITING_GOODS",
          },
          {
            label: "卖家已收货",
            value: "RECEIVED_GOODS",
          },
          {
            label: "退款中",
            value: "REFUND_OF",
          },
          {
            label: "退款完成",
            value: "REFUND_FINISH",
          },
        ],*/
      // orderType: [
      //   {
      //     label: "全部",
      //     value: "",
      //   },
      //   {
      //     label: "普通订单",
      //     value: "GOODS_ORDER",
      //   },
      //   {
      //     label: "团购订单",
      //     value: "GROUP_ORDER",
      //   },
      //   {
      //     label: "秒杀订单",
      //     value: "SECKILL_ORDER",
      //   },
      //   {
      //     label: "直播间订单",
      //     value: "ROOM_ORDER",
      //   },
      // ],
      /*   orderType: [
          {
            label: "全部",
            value: "",
          },
          ,
        ],*/

      goodsTypeList: createOptionsByDict("PRODUCT_TYPE"),
      orderType: [
        { label: "全部", value: "" },
        ...createOptionsByDict("ORDER_TYPE"),
      ],
      productTypeList: [
        { label: "全部", value: "" },
        { label: "标品", value: "2" },
        { label: "定制品", value: "1" },
        { label: "虚拟商品", value: "3" },
      ],
      url: "/order/page",
      form: this.$form.createForm(this, { name: "table_search" }),
      remarkShow: false,
      cancellationShow: false,
      shoppingInfoShow: false,
      priceChangeShow: false,
      pickUpVerificationShow: false,
      withdrawMoneyInfoShow: false,
      batchDeliverShow: false,
      // 根据子订单导出
      exportList: [],
    };
  },
  computed: {
    defaultParams() {
      return { reason: this.$route.query.orderId };
    },
  },
  watch: {},
  beforeCreate() {},

  created() {},
  mounted() {
    this.masterOrderId = this.$route.query.orderId;
  },

  beforeRouteEnter(to, from, next) {
    console.log("beforeRouteEnter,from,to", from, to);

    // next(vm=>{
    //   let listUpdate=vm.$store.state.listUpdate || {};
    //   console.log('vm',listUpdate)
    //   to.meta.isBack=(from.name=='OrderListInfo' && !listUpdate.isUpdate);
    // });
    console.log("from,to", from, to);
    // alert(to.query.back)
    to.meta.isBack =
      (from.name == "OrderListInfo" ||
        from.name == "ProductCommodityManageCommodityManageAddEditProduct") &&
      to.query.back;
    to.meta.keepAlive = true;
    next();
  },

  activated() {
    this.$nextTick(() => {
      console.log("activated", this.$refs);
      if (!this.$route.meta.isBack) {
        this.$refs.searchtable.resetForm();
        this.masterOrderId = this.$route.query.orderId;
      }
      this.masterOrderId = this.$route.query.orderId;
      this.$route.meta.isBack = false;
    });
  },

  filters: {
    filterPrice(value) {
      if (!value) return "0.00";
      return `${(value / 100).toFixed(2)}`;
    },

    filterOrderStatus(value) {
      switch (value) {
        case "ORDER_UNPAID":
          return "待付款";
        case "ORDER_CANCEL":
          return "订单已取消"; // 已取消
        case "ORDER_UN_ISSUE":
          return "待发货"; // 待发货
        case "ORDER_LEFT_WAIT":
          return "待自提"; // 待自提
        case "ORDER_UN_RECEIVED":
          return "待收货"; // 待收货
        case "ORDER_UN_EVALUATE":
          return "待评价"; // 待评价
        case "ORDER_FINISH":
          return "已完成"; // 已完成
      }
    },

    filterDistribution(val) {
      if (val == 1) {
        return "定点自提";
      } else if (val == 0) {
        return "快递配送";
      } else if (val == 2) {
        return "定点配送";
      }
      return "快递配送";
    },
    orderTypeList(value) {
      switch (value) {
        case "GOODS_ORDER":
          return "普通订单";
        case "GROUP_ORDER":
          return "团购订单";
        case "SECKILL_ORDER":
          return "秒杀订单";
        case "ROOM_ORDER":
          return "直播间订单";
        default:
          return "普通订单";
      }
    },
    orderFormType(value) {
      switch (value) {
        case 1:
          return "金桔有品";
        // return "微信小程序";
        case 2:
          return "金牌厨柜官方号";
        default:
          return "金桔有品";
        // return "微信小程序";
      }
    },
  },

  // 方法集合
  methods: {
    // 带ID页面跳转
    openNew(record) {
      console.log(record, "进来了");
      this.$router.push({
        name: "OrderListInfo",
        query: {
          id: record.id,
          returnGoodsStatus: record.returnGoodsStatus,
          repairsType: record.repairsType,
        },
      });
    },
    // 打开商品详情
    openGoodsInfo(record) {
      let params = {
        id: record.goodsId,
        current: this.paginations.current,
        source: "order",
      };
      this.$router.push({
        name: "ProductCommodityManageCommodityManageAddEditProduct",
        query: params,
      });
    },
    // 判断打开哪个窗口
    openInfo(record, type) {
      console.log(record);
      this.currentRecord = record;
      switch (type) {
        case "remarks":
          this.remarkShow = true;
          break;
        case "cancellation":
          this.cancellationShow = true;
          break;
        case "shoppingInfo":
          this.shoppingInfoShow = true;
          break;
        case "priceChange":
          this.priceChangeShow = true;
          break;
        case "pickUpVerification":
          this.pickUpVerificationShow = true;
          break;
        case "withdrawMoneyInfo":
          this.withdrawMoneyInfoShow = true;
          break;
      }
      // if (type == "remarks") {
      //   this.remarkShow = true;
      // } else if (type == "cancellation") {
      //   this.cancellationShow = true;
      // } else if (type == "shoppingInfo") {
      //   this.shoppingInfoShow = true;
      // } else if (type == "priceChange") {
      //   this.priceChangeShow = true;
      // }
    },
    //分页
    tableChange(current, size) {
      // 调用组件handleSubmit 有改变自己改下
      this.paginations.current = current;
      this.paginations.size = size;
      this.$refs.searchtable.getList(current, size);
      console.log("layout", this.$refs.layout);
    },

    dataSourceChange(data) {
      //监听table数据 处理合并单元格
      // console.log("data", data);
      if (data && data.records && data.records.length > 0) {
        data.records.forEach((item) => {
          this.$set(item, "firstImg", item.goodsImg.split(",")[0]);
        });
      }
      this.orderList = (data && data.records) || [];
      console.log(" 订单列表:", this.orderList);
      this.paginations.current = (data && data.current) || 1;
      this.paginations.total = (data && data.total) || 0;
      this.paginations.size = (data && data.size) || 10;
    },
    handleCancel(type) {
      switch (type) {
        case "remarks":
          this.remarkShow = false;
          break;
        case "cancellation":
          this.cancellationShow = false;
          break;
        case "shoppingInfo":
          this.shoppingInfoShow = false;
          break;
        case "priceChange":
          this.priceChangeShow = false;
          break;
        case "pickUpVerification":
          this.pickUpVerificationShow = false;
          break;
      }
    },
    handleSubmit(type) {
      switch (type) {
        case "remarks":
          this.remarkShow = false;
          this.$refs.searchtable.getList(
            this.paginations.current,
            this.paginations.size
          );
          break;
        case "cancellation":
          this.cancellationShow = false;
          this.$refs.searchtable.getList(
            this.paginations.current,
            this.paginations.size
          );
          break;
        case "shoppingInfo":
          this.shoppingInfoShow = false;
          this.$refs.searchtable.refreshTable();
          break;
        case "priceChange":
          this.priceChangeShow = false;
          this.$refs.searchtable.refreshTable();
          break;
        case "pickUpVerification":
          this.pickUpVerificationShow = false;
          this.$refs.searchtable.refreshTable();
          break;
      }
    },

    getTypeName(type, value) {
      return findDictNameByValue(type, value);
    },
    /*   checkboxChange(e,data){

        console.log(e.target.checked,data)

        if ( e.target.checked){
          this.exportList.push(data)
        }else {
          this.exportList = this.exportList.filter((item,index)=>{
               return item.orderGoodsNo !== data.orderGoodsNo
          })
        }
        console.log(this.exportList)
      },*/
    // 据子订单号导出 订单
    exportOrders() {
      // order:export

      /*        let orderLists = []
          if (this.exportList.length===0){
             return this.$message.warn("请至少选择一个订单")
          }
          // 只要订单号
          this.exportList.forEach((item,index)=>{
            orderLists.push(item.orderGoodsNo)
          })

          console.log("最后导出的子订单数组,",orderLists)
          let orderListsString = orderLists.join(',')
          //  调一下导出的接口
          this.$export(url,{orderGoodsNo:orderListsString})  */

      let url = "/order/export";
      // this.form.setFieldsValue({["goodsName"]:'asd'})

      let goodsName = this.form.getFieldValue("goodsName");
      let userName = this.form.getFieldValue("userName");
      let orderNo = this.form.getFieldValue("orderNo");
      let orderGoodsNo = this.form.getFieldValue("orderGoodsNo");
      let orderType = this.form.getFieldValue("orderType");
      let orderStatus = this.form.getFieldValue("orderStatus");
      let orderFromType = this.form.getFieldValue("orderFromType");
      let returnGoodsStatus = this.form.getFieldValue("returnGoodsStatus");
      let createStartDate;
      let createEndDate;
      if (!!this.form.getFieldValue("createStartDate-createEndDate")) {
        createStartDate = this.form.getFieldValue(
          "createStartDate-createEndDate"
        )[0];
        createEndDate = this.form.getFieldValue(
          "createStartDate-createEndDate"
        )[1];
      }
      let params = {
        goodsName,
        userName,
        orderNo,
        orderGoodsNo,
        orderType,
        orderStatus,
        orderFromType,
        returnGoodsStatus,
        createStartDate,
        createEndDate,
      };

      console.log("导出的参数:", params);
      this.$export(url, { ...params });
    },
    // 批量发货
    batchDeliver() {
      this.batchDeliverShow = true;
    },
    handleSubmitBatchDeliver(data) {
      this.batchDeliverShow = false;
    },
    // 打印订单
    printOrder(dataSourceItem) {
      console.log(dataSourceItem);
      // order/printOrder？orderId=xxx  Get
      // order:print
      this.$get("/order/printOrder", { orderId: dataSourceItem.id }).then(
        (res) => {
          if (res && res.returnCode === 1000) {
            this.$message.success("打印成功");
            this.$refs.searchtable.refreshTable(); // handleSearch
          }
        }
      );
    },

    // 取消退款 关闭退款窗口
    cancelWithdrawMoney() {
      this.withdrawMoneyInfoShow = false;
    },
    // 接退款原因数据,提交退款原因 刷新列表
    handleSubmitWithdrawMoneyInfo(formData) {
      console.log("数据", formData);
      let reasonDesc = formData.reasonDesc;
      // 非其他 就清除reason
      if (formData.reason !== "其它") {
        reasonDesc = "";
      }
      let params = {
        reasonDesc,
        orderGoodsId: formData.id,
        reason: formData.reason,
        repairsType: 1,
      };
      console.log("要提交的原因数据:", params);
      this.$post("/repairs/apply", { ...params }).then((res) => {
        if (res && res.returnCode === 1000) {
          console.log("res:", res);
          this.withdrawMoneyInfoShow = false;
          this.$refs.searchtable.refreshTable(); // handleSearch
        }
      });
    },
    //手机号点击跳到客户详情页
    // http://localhost:8888/#/customer/userInfo?id=418185541146640384
    // http://localhost:8888/#/customer/userInfo?id=undefined
    toClientDetailPage(dataSourceItem) {
      // console.log(`${ location.origin }/goldenhome/ghs/admin`)
      /*  console.log(`${ location.origin+location.pathname  }`)

        var a = document.createElement('a');
        a.setAttribute('href', `${location.origin+location.pathname}/#/customer/userInfo?id=${record.userId}`);
        a.setAttribute('target', '_blank');
        // a.setAttribute('target', '_blank');
        document.body.appendChild(a);
        a.click();*/

      let routes = this.$router.resolve({
        name: "CustomerUserInfo",
        query: { id: dataSourceItem.userId, source: "order" },
      });
      window.open(routes.href, "_blank");
      // http://10.0.1.137:8888//#/customer/userInfo?id=464762986454249472
      // http://10.0.1.137:8888//#/customer/userInfo?id=464762986454249472&source=order
      /*   this.$router.push({
          name: "CustomerUserInfo",
          query: {
            id: record.userId,
          },
        });*/
    },
  },
};
</script>
<style rel='stylesheet/less' lang='less' scoped>
//@import url();
.paginations {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}
.disPadding {
  padding: 0;
}

.tab_header {
  display: flex;
  height: 40px;
  background-color: #f7f8fa;
  width: 100%;
  line-height: 40px;
  margin: 10px 0;
  color: #323233;
  box-sizing: border-box;
  font-weight: bold;
  .item {
    flex: 1;
    text-align: center;
    white-space: nowrap;
    padding: 0 10px;
  }
  .item--goods-info {
    padding: 0;
    display: flex;
    .item__cell {
      flex: 1;
    }
    .goods-basic {
      padding: 0 12px;
      text-align: left;
      flex-basis: 65%;
    }
    .goods-num {
      padding: 0 5px;
      flex-basis: 20%;
    }
    .goods-refund {
      padding: 0 10px;
      flex-basis: 60px;
    }
  }
}
.tab_content {
  margin-bottom: 14px;
  word-break: break-word;
  .order-item__header {
    .basic-info {
      display: flex;
      justify-content: space-between;
      min-width: 790px;
      background-color: #f7f8fa;
      border: 1px solid #ebedf0;
      padding: 12px 10px;
      .info-wrapper {
        display: flex;
        flex-wrap: wrap;
        .basic {
          margin-right: 15px;
        }
      }
    }
  }
  .order-item__body {
    display: flex;
    border: 1px solid #ebedf0;
    border-top: none;
    .cell--goods-list {
      display: flex;
      flex-direction: column;
      padding: 0;
      align-items: flex-start;
    }
    .cell {
      border-right: 1px solid #ebedf0;
      flex: 1;
      padding: 10px;
      display: flex;
      justify-content: center;
      align-items: center;
      min-width: 60px;
    }
    .goods-info {
      flex: 1;
      flex-basis: 65%;
      padding: 10px 12px;
    }
    .goods-item {
      display: flex;
      flex: 1;
      width: 100%;
      box-sizing: border-box;
    }
    .goods-num {
      display: flex;
      flex-direction: column;
      justify-content: center;
      padding: 5px;
      flex-basis: 23%;
    }
    .rc-goods-cell {
      display: flex;
      box-sizing: border-box;
      width: 100%;
      max-width: 240px;
      .rc-goods-cell-left {
        flex-grow: 0;
        margin-right: 10px;
      }

      .rc-goods-cell-right {
        flex-grow: 1;
        padding: 4px 0;
        .rc-goods-cell-name {
          color: #323232;
          font-size: 14px;
          line-height: 18px;
          word-break: break-all;
        }
        .rc-goods-cell-info {
          margin-top: 2px;
          word-break: break-all;
          font-size: 12px;
          color: #969799;
        }
      }
    }

    .link-button {
      display: block;
      margin-bottom: 5px;
    }
  }

  .order-item__footer {
    border: 1px solid #ebedf0;
    border-top: 0;
    padding: 3px 10px;
    color: #969799;
  }
}
</style>
